<div style="width:300px;margin:10px auto 20px auto;">
    <br />
    类型：<input id="name" class="txt" value ="{$name}" />
    <if condition="$id"><input type="hidden" id="id" class="txt" value ="{$id}" /></if>
</div>
<div >
    <input type="button" class="btn_b" onclick="editType($( '#name' ).val() )" value="确定" />
</div>
<script>
function editType( name ){
  <if condition="$id">
  var id = '{$id}';
  $.post( '__URL__&act=doEditType',{name:name,id:id},function( res ){
      if( res > 0 ){
          ui.box.close();
          ui.success('修改成功');
          $('#name_'+id).html('<a href="{:U('/Admin/eventlist')}&type='+id+'">'+name+'</a>');
      }else{
          ui.error( "修改失败" );
      }
  });
  <else />
  $.post( '__URL__&act=doAddType',{name:name},function( id ){
      if( id > 0 ){
          ui.box.close();
          ui.success('添加成功');
          $('#event_list').append(
                '<tr id="list_'+id+'">'+
                  '<td><input type="checkbox" name="checkbox" id="checkbox2" onclick="checkon(this)" value="'+id+'"></td>'+
                  '<td>'+id+'</td>'+
                  '<td><a href="{:U('/Admin/eventlist')}&type='+id+'">'+name+'</a></td>'+
                  '<td>0</td>'+
                  '<td><a href="javascript:c.edit_tab('+id+')">编辑</a> <a href="javascript:c.del('+id+')">删除</a></td>'+
                '</tr>'
          );
      }else{
          ui.error( "添加分类失败" );
      }
  });
  </if>
}
</script>